package com.ysg.widget.dialog;

import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.wang.avi.AVLoadingIndicatorView;
import com.ysg.R;
import com.ysg.base.BaseDialog;

public class LoadingDialog extends BaseDialog {
    private String mMessage = "加载中...";
    private String mIndicator = "LineSpinFadeLoaderIndicator";
    private TextView tvLoading;
    private AVLoadingIndicatorView avLoadingIndicatorView;

    public LoadingDialog(@NonNull Context context) {
        super(context, R.style.LoadingDialog);
        mContext = context;
    }

    public LoadingDialog(@NonNull Context context, String message) {
        super(context, R.style.LoadingDialog);
        mContext = context;
        mMessage = message;
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_loading;
    }

    public void initView() {
        setCanceledOnTouchOutside(false);
        setSquare(true);
        setWidthScale(0.3f);
        setAlpha(1f);
//        setAlpha(0.5f);

        tvLoading = findViewById(R.id.tv_loading);
        avLoadingIndicatorView = findViewById(R.id.iv_loading);
    }

    @Override
    public void initData() {
        avLoadingIndicatorView.setIndicator(mIndicator);
        tvLoading.setText(mMessage);
    }

    @Override
    public void initListener() {

    }

    public void setMessage(String message) {
        tvLoading.setText(message);
    }

}
